'use strict';
function compare(arr1,arr2){
  if(arr1<arr2){
    return -1;
  }
  else if(arr1>arr2){
    return 1;
  }
  else{
    return 0;
  }
}


function make_num_into_letter(item){
  let num1=item%26;
  let num2=Math.floor(item/26);
  if(num2==0){
   item=String.fromCharCode(num1+96);
  }
  else if(num2==1&&num1==0){
    item=String.fromCharCode(122);
  }
  else if(num2>1&&num1==0){
    item=String.fromCharCode(num2-1+96,122);
  }
  else{
    item=String.fromCharCode(num2+96,num1+96);
  }
return item;
}

function median_to_letter(collection) {
  let result;
  collection.sort(compare);
  if(collection.length%2==0){
     result=(collection[collection.length/2]+collection[collection.length/2-1])/2;
  }
  else{
    result=collection[(collection.length-1)/2];
  }
  result=Math.ceil(result);
  result=make_num_into_letter(result);
  console.log(result);
  return result;
}

module.exports = median_to_letter;
median_to_letter([20,21,22,23,24,25,26,27,28,29,
  30,31,32,33,34,35,36,37,38,39,
  40,41,42,43,44,45,46,47,48,49,
  50,51,52,53]);
